<!DOCTYPE html>
<html>

<head>
    <#include "/xhc/admin/components/meta.html" />
    <title>出出帮火车奇妙世界后台 ${metaTitleSuffix!}</title>
    <#include "/xhc/admin/components/stylesheets.html" />
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="1-1" />
            <#include "/xhc/admin/components/menu.html" />
            <el-container>
                <#include "/xhc/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-date-picker v-model="date" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" @change="onDateChange" unlink-panels="true">
                        </el-date-picker>
                        <el-button @click='onEdit()'>修改</el-button>
                        <el-button @click='onEditInfo()'>车票信息</el-button>
                        <el-button @click='onActice()'>激活</el-button>
                        <el-table :data="items" style="width: 100%">
                            <el-table-column prop="time" label="日期">
                                <template slot-scope="scope">
                                    <span>{{scope.row.time}}</span>
                                    <span v-if='scope.row.disable==1' style="color: red"> 暂停售票</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="tips" label="">
                            </el-table-column>
                            <el-table-column prop="title1" label="">
                            </el-table-column>
                            <el-table-column prop="price1" label="票价">
                            </el-table-column>
                            <el-table-column prop="count" label="购买数量">
                            </el-table-column>
                            <el-table-column prop="limit" label="总票数">
                            </el-table-column>
                            <el-table-column prop="left" label="剩余数量">
                            </el-table-column>
                            <el-table-column label="操作">
                                <template slot-scope="scope">
                                    <el-button @click='updateTicketInfo(scope.row)'>刷新</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <#include '/components/page.html' />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/xhc/admin/components/footer.html" />
    </div>
    <#include "/xhc/admin/components/scripts.html" />
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                date: ['${startDate!}', '${endDate!}'],
                items: JSON.parse(`${items![]}`)
            }
        },
        mounted: function() {},
        methods: {
            onDateChange(val) {
                var keys = [
                    { key: 'startDate', value: val[0] },
                    { key: 'endDate', value: val[1] }
                ]
                goPage(1, keys)
            },
            updateTicketInfo(item) {
                var params = {
                    ticketId: item.id
                }
                var url = '/xhc/web/ticket/updateTicketInfo'
                axiosRequest(params, url, '')

            },
            onEditInfo(item) {
                window.location.href = '/xhc/web/ticket/info'
            },
            onEdit() {
                window.location.href = '/xhc/web/ticket/edit'
            },
            fakePay(item) {
                // msg('sss')
                // function axiosRequestPro(params, url, success, fail, complete) {
                // function axiosRequest(params, url, redirect) {
                var params = {
                    ticketId: item.id
                }
                var url = '/xhc/web/ticket/fakePay'
                axiosRequest(params, url, '')

            },
            onActice() {
                vue.$prompt('请输入票号', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                }).then(({ value }) => {
                    var params = {
                        code: value
                    }
                    var url = '/xhc/web/ticket/active'
                    axiosRequest(params, url, '')
                }).catch(() => {});
            }
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
    <script>
    // vue.tableData = ${items!};
    </script>
</body>

</html>